const state = {
  sidebar: {
    opened: true,
    withoutAnimation: false
  },
  app_name: '数据服务平台',
  viewTempalge: 'web'
}

const mutations = {
  SET_OPENED: state => {
    state.sidebar.opened = !state.sidebar.opened
    state.sidebar.withoutAnimation = false
  },
  SET_VIEWTEMPALGE: (state, val) => {
    state.viewTempalge = val
  },
  CLOSE_SIDEBAR: (state, withoutAnimation) => {
    state.sidebar.opened = false
    state.sidebar.withoutAnimation = withoutAnimation
  },
  TOGGLE_DEVICE: (state, device) => {
    state.device = device
  },
  SET_SIZE: (state, size) => {
    state.size = size
  }
}
const actions = {
  setVisitTemplate({commit},val) {
    commit('SET_VIEWTEMPALGE',val)
  },
  setOpened({commit}) {
    commit('SET_OPENED')
  },
  closeSideBar({ commit }, { withoutAnimation }) {
    commit('CLOSE_SIDEBAR', withoutAnimation)
  },
  toggleDevice({ commit }, device) {
    commit('TOGGLE_DEVICE', device)
  },
  setSize({ commit }, size) {
    commit('SET_SIZE', size)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}